var util = require('../../libs/util.js');
var app = getApp();
Page({
  data: {
    index: '',
    delivery_date: ''//util.dateObjectformat(new Date(),'yyyy-MM-dd')
  },
  onShareAppMessage: function () {
    return {
      title: app.appName,
      path: '/pages/index/index'
    }
  },
  onLoad: function (e) {
    wx.setNavigationBarTitle({ "title": app.appName +"--发货点信息" });
    this.setData({
      index: e.index,
      shipper: e.shipper == 'undefined' ? '' : e.shipper,
      shipper_phone: e.shipper_phone == 'undefined' ? '' : e.shipper_phone  
    });
    wx.removeStorage({
      key: 'warehouseConfig',
      success: function (res) {
      }
    });
  },
  onReady: function () {
    wx.hideToast()
  },
  bindInput: function (e) {
    var item = String(e.currentTarget.id), item_value = {};
    item_value[item] = e.detail.value;
    this.setData(item_value);
  },
  confirmData: function () {
    // if (!this.data.delivery_date || !this.data.loading_time || !this.data.depart_time || !this.data.shipper || !this.data.shipper_phone) {
    //   wx.showToast({
    //     title: "有未输入项",
    //     image: "/images/wrong.svg",
    //     duration: 3000
    //   });
    //   return false;
    // };
    wx.setStorage({
      key: "warehouseConfig",
      data: { alias: this.data.alias, shipper: this.data.shipper, shipper_phone: this.data.shipper_phone, index: this.data.index}
    });
    wx.navigateBack({
      delta: 1
    });
  },
  cancelConfirmData: function () {
    wx.navigateBack({
      delta: 1
    });
  }
});